﻿<Window x:Class="ResourceBlender_Express.WinImport"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:loc="clr-namespace:ResourceBlender_Express"
    xmlns:validators="clr-namespace:ResourceBlender_Express.Validators"
    xmlns:props="clr-namespace:ResourceBlender_Express.Properties"
    loc:WindowService.EscapeClosesWindow="True" Loaded="Window_Loaded"
    Title="Import" WindowStartupLocation="CenterOwner"
    Height="300" Width="400" MinHeight="200" MinWidth="350" MaxHeight="370" MaxWidth="400"
    Style="{StaticResource {x:Type Window}}" Icon="/ResourceBlender-Express;component/Resources/images/resourceblender.ico" ResizeMode="NoResize" SizeToContent="Height">
    <Window.CommandBindings>
        <CommandBinding Command="loc:ResourceBlenderCommands.Browse" Executed="BrowseInputFile" />
        <CommandBinding Command="loc:ResourceBlenderCommands.Abort" Executed="AbortImport" CanExecute="CanExecuteAbort" />
        <CommandBinding Command="NavigationCommands.PreviousPage" Executed="MovePreviousPage" CanExecute="CanMovePage" />
        <CommandBinding Command="NavigationCommands.NextPage" Executed="MoveNextPage" CanExecute="CanMovePage" />
    </Window.CommandBindings>
    <Window.Resources>
        <props:Settings x:Key="settings" />
    </Window.Resources>
    <DockPanel LastChildFill="true">
        <StatusBar DockPanel.Dock="Bottom" Height="24">
            <StatusBarItem x:Name="lblStatus" Visibility="Hidden">Loading</StatusBarItem>
            <StatusBarItem>
                <ProgressBar x:Name="prgStatus" IsIndeterminate="True" Visibility="Hidden" />
            </StatusBarItem>
        </StatusBar>
        
        <Grid DockPanel.Dock="Bottom" MinHeight="10" Margin="6,0,6,6">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <Button Grid.Column="0" x:Name="btnPrevious" MinWidth="70" Command="NavigationCommands.PreviousPage" Visibility="Hidden">_Previous</Button>
            <Button Grid.Column="2" x:Name="btnAbort" MinWidth="70" Command="loc:ResourceBlenderCommands.Abort" Visibility="Hidden">_Abort</Button>
            <Button Grid.Column="3" x:Name="btnNext" MinWidth="70" Command="NavigationCommands.NextPage" IsDefault="True">_Next</Button>
        </Grid>
        
        <TabControl x:Name="tabWizard" DockPanel.Dock="Top" Margin="6,6,6,0" DataContext="{StaticResource settings}" Background="Transparent" BorderThickness="0" SelectedIndex="0">
            <TabItem Height="0" x:Name="tbStart">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    
                    <Label Grid.Row="0" Grid.Column="0" VerticalAlignment="Bottom">Filename</Label>
                    <TextBox x:Name="txtFilename" Grid.Row="0" Grid.Column="1">
                        <Binding Path="Default.LastImportFile" Mode="TwoWay">
                            <Binding.ValidationRules>
                                <validators:StringValidationRule MinimumLength="0" ErrorMessage="Filename to import must be specified" />
                            </Binding.ValidationRules>
                        </Binding>
                    </TextBox>
                    <Button Grid.Row="1" Grid.Column="1" Command="loc:ResourceBlenderCommands.Browse" HorizontalAlignment="Right">Browse...</Button>
                    
                    <Label Grid.Row="2" Grid.Column="0" VerticalAlignment="Top">Type</Label>
                    <ListBox Grid.Row="2" Grid.Column="1" x:Name="lstType" Style="{StaticResource RadioListTemplate}" SelectedValuePath="Tag">
                        <ListBoxItem Tag="auto" IsSelected="true">Auto</ListBoxItem>
                        <ListBoxItem Tag="properties">Java (.properties)</ListBoxItem>
                        <ListBoxItem Tag="resx">.NET Managed Resources (.resx)</ListBoxItem>
                        <ListBoxItem Tag="po">GNU gettext / Portable Object (.po)</ListBoxItem>
                        <ListBoxItem Tag="rbt">Translation Database (.rbt)</ListBoxItem>
                        <ListBoxItem Tag="xml">XML Backup</ListBoxItem>
                        <ListBoxItem Tag="xmlxls">XML Spreadsheet</ListBoxItem>
                    </ListBox>
                </Grid>
            </TabItem>
            <TabItem Height="0" x:Name="tbXML"><!-- Component selection for XML import/export -->
                <StackPanel>
                    <TextBlock>Select which components to import.</TextBlock>
                    <GroupBox Header="Include" Margin="2">
                        <StackPanel>
                            <CheckBox x:Name="chkApplications" IsChecked="{Binding Path=Default.BackupApplications,Mode=TwoWay}">Applications</CheckBox>
                            <CheckBox x:Name="chkElements" IsChecked="{Binding Path=Default.BackupElements,Mode=TwoWay}">Elements</CheckBox>
                            <CheckBox x:Name="chkTemplates" IsChecked="{Binding Path=Default.BackupTemplates,Mode=TwoWay}">Templates</CheckBox>
                            <CheckBox x:Name="chkResources" IsChecked="{Binding Path=Default.BackupResources,Mode=TwoWay}">Resources</CheckBox>
                        </StackPanel>
                    </GroupBox>
                    <CheckBox x:Name="chkClearDatabase">Clear Database Before Restoring</CheckBox>
                </StackPanel>
            </TabItem>
            <TabItem Height="0" x:Name="tbXMLXLS"><!-- Just a prompt for XML spreadsheet import -->
                <TextBlock>Uploaded XML spreadsheet. Click 'Import' to start.</TextBlock>
            </TabItem>
            <TabItem Height="0" x:Name="tbResources"><!-- Select application for resource file import -->
                <StackPanel>
                    <TextBlock x:Name="txtBundleSummary" TextWrapping="Wrap" />
                    <ListBox x:Name="lstApplications" Style="{StaticResource RadioListTemplate}" />
                </StackPanel>
            </TabItem>
            <TabItem Height="0" x:Name="tbRBT"><!-- Language selection for RBT translation database import -->
                <DockPanel LastChildFill="True">
                    <TextBlock DockPanel.Dock="Top" >Uploaded translation database. Select languages to import.</TextBlock>
                    <ListBox x:Name="lstLanguages" DockPanel.Dock="Bottom" VerticalAlignment="Stretch" MinHeight="120" ItemTemplate="{StaticResource LanguageListItem}" 
                             SelectedValuePath="Key" SelectionMode="Extended" />
                </DockPanel>
            </TabItem>
            <TabItem Height="0" x:Name="tbProgress">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="*" MinHeight="220" MaxHeight="300" />
                        <RowDefinition Height="24" />
                    </Grid.RowDefinitions>
                    
                    <TextBlock Grid.Row="0">Progress</TextBlock>
                    <RichTextBox Grid.Row="1" IsReadOnly="True" VerticalAlignment="Stretch" VerticalScrollBarVisibility="Visible">
                        <FlowDocument>
                            <Paragraph>
                                <Span x:Name="txtProgress"></Span>
                            </Paragraph>
                        </FlowDocument>
                    </RichTextBox>
                    <ProgressBar Grid.Row="2" x:Name="prgProgress" IsIndeterminate="True" />
                </Grid>
            </TabItem>
        </TabControl>
    </DockPanel>
</Window>
